import request from '@/utils/request'

const base_api = '/admin/system/sysRole'
// 角色列表
export const GetSysRoleListByPage = (current,limit,queryDto) => {
  return request({
    url: `${base_api}/findByPage/${current}/${limit}`,
    method: 'post',
    data: queryDto,
  })
}

export const addSysRole = (sysRoleData)=>{
    return request({
        url: `${base_api}/addSysRole`,
        method: 'post',
        data: sysRoleData,
    })
}

export const updateSysRole = (sysRoleData)=>{
  return request({
      url: `${base_api}/updateSysRole`,
      method: 'put',
      data: sysRoleData,
  })
}

export const deleteSysRole = (id)=>{
  return request({
    url: `${base_api}/deleteSysRole/${id}`,
    method: 'delete',
  })
}

// 查询所有的角色数据
export const GetAllRoleList = (userId) => {
  return request({
      url: `${base_api}/findAllRoles/${userId}`,
      method: 'get'
  })
}

// 查询指定角色所对应的菜单id
export const GetSysRoleMenuIds = (roleId) => {
  return request({
      url: "/admin/system/sysRoleMenu/findSysRoleMenuByRoleId/"+ roleId,
      method: 'get'
  })
}

// 根据角色分配菜单请求方法
export const DoAssignMenuIdToSysRole = (assignMenuDto) => {
  return request({
      url: "/admin/system/sysRoleMenu/doAssign",
      method: 'post',
      data: assignMenuDto
  })
}
